package com.hedl.classroom.controller;

import com.hedl.classroom.model.po.Dictionary;
import com.hedl.classroom.service.DictionaryService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
@Api(value = "数据字典前端控制器",tags = {"数据字典前端控制器"})
public class DictionaryController {

    @Resource
    @ApiModelProperty(value = "数据字典前端控制器",dataType = "Object")
    private DictionaryService dictionaryService;

    @GetMapping("/dictionary/all")
    @ApiOperation(value = "查询所有数据字典内容")
    public List<Dictionary> queryAll(){
        return dictionaryService.queryAll();
    }

    @GetMapping("/dictionary/code/{code}")
    @ApiOperation(value = "code查询数据字典")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code",value = "数据字典代码",required = true,dataType = "String")
    })
    public Dictionary getByCode(@PathVariable("code") String code){
        return dictionaryService.getByCode(code);
    }


}
